import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { ComponentInternalInstance } from 'vue'

export enum Api {
  list = '/park/list',
  delete = '/park/delete',
  batchDelete = '/park/batchDelete',
  detail = '/park/detail',
  export = 'park/export',
}

// 获取列表
export const parkList = (data): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 删除
export const parkDelete = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 批量删除
export const parkBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 获取设备详情
export const parkDetail = (data: any) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}

// 导出
export const orderExport = (data: any) => {
  const { proxy } = getCurrentInstance() as ComponentInternalInstance
  proxy?.download(Api.export, data, `park_${new Date().getTime()}.xlsx`)
  return request({
    url: Api.export,
    method: 'post',
    data,
  })
}
